package com.cml.test;

import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.dsl.Disruptor;

/**
 * 姓名：陈茂林
 * 时间：2023/12/21
 * 描述：
 */
public class OrderEventPublish {
    private RingBuffer ringBuffer;
    public OrderEventPublish(Disruptor<OrderEvent> disruptor){
        this.ringBuffer=disruptor.getRingBuffer();
    }
    public void publish(){
        for (int i = 0; i < 100; i++) {
            long seq = this.ringBuffer.next();
            try {
                OrderEvent orderEvent = (OrderEvent) this.ringBuffer.get(seq);
                orderEvent.setName(i + "");
            }finally {
                this.ringBuffer.publish(seq);
            }

        }
    }
}
